<?php
namespace Admin\Controller;
use Think\Controller;
class OperateController extends Controller {
    //TP构造函数
    public function _initialize(){
        //自动加载的类
        new \Org\Admin_autoload();
    }
    //
    public function index(){
        $data['title']='运营设置 运营 - 找金银网';
        //获取产品分类列表
        if(I('path.2')>0){
            $page=I('path.2');
        }else{
            $page=1;
        }
        $perpage=10;
        $Model=D("Code");
        $Model->page=$page;
        $Model->perpage=$perpage;
        $list=$Model->get_list();
        //分页相关
        $info_total=$Model->get_info_total();
        $page_total=ceil($info_total/$perpage);
        if($page!=1&&$page_total>1){
            $last_page=$page-1;
        }else{
            $last_page=1;
        }
        if($page_total>$page){
            $next_page=$page+1;
        }else{
            $next_page=$page;
        }
        $pager['current_page']=$page;
        $pager['last_page']=$last_page;
        $pager['next_page']=$next_page;
        $pager['page_total']=$page_total;
        $pager['info_total']=$info_total;
        $this->assign("data", $data);
        $this->assign("list", $list);
        $this->assign("pager", $pager);
        $this->display();
    }
    //
    public function voucher(){
        $data['title']='代金券管理 运营 - 找金银网';
        //获取产品分类列表
        if(I('path.2')>0){
            $page=I('path.2');
        }else{
            $page=1;
        }
        $perpage=10;
        $Model=D("Code");
        $Model->page=$page;
        $Model->perpage=$perpage;
        $list=$Model->get_list();
        //分页相关
        $info_total=$Model->get_info_total();
        $page_total=ceil($info_total/$perpage);
        if($page!=1&&$page_total>1){
            $last_page=$page-1;
        }else{
            $last_page=1;
        }
        if($page_total>$page){
            $next_page=$page+1;
        }else{
            $next_page=$page;
        }
        $pager['current_page']=$page;
        $pager['last_page']=$last_page;
        $pager['next_page']=$next_page;
        $pager['page_total']=$page_total;
        $pager['info_total']=$info_total;
        $this->assign("data", $data);
        $this->assign("list", $list);
        $this->assign("pager", $pager);
        $this->display();
    }
    //
    public function coupon(){
        $data['title']='优惠券管理 运营 - 找金银网';
        //获取产品分类列表
        if(I('path.2')>0){
            $page=I('path.2');
        }else{
            $page=1;
        }
        $perpage=10;
        $Model=D("Code");
        $Model->page=$page;
        $Model->perpage=$perpage;
        $list=$Model->get_list();
        //分页相关
        $info_total=$Model->get_info_total();
        $page_total=ceil($info_total/$perpage);
        if($page!=1&&$page_total>1){
            $last_page=$page-1;
        }else{
            $last_page=1;
        }
        if($page_total>$page){
            $next_page=$page+1;
        }else{
            $next_page=$page;
        }
        $pager['current_page']=$page;
        $pager['last_page']=$last_page;
        $pager['next_page']=$next_page;
        $pager['page_total']=$page_total;
        $pager['info_total']=$info_total;
        $this->assign("data", $data);
        $this->assign("list", $list);
        $this->assign("pager", $pager);
        $this->display();
    }
    //
    public function activity(){
        $data['title']='活动管理 运营 - 找金银网';
        //获取产品分类列表
        if(I('path.2')>0){
            $page=I('path.2');
        }else{
            $page=1;
        }
        $perpage=10;
        $Model=D("Code");
        $Model->page=$page;
        $Model->perpage=$perpage;
        $list=$Model->get_list();
        //分页相关
        $info_total=$Model->get_info_total();
        $page_total=ceil($info_total/$perpage);
        if($page!=1&&$page_total>1){
            $last_page=$page-1;
        }else{
            $last_page=1;
        }
        if($page_total>$page){
            $next_page=$page+1;
        }else{
            $next_page=$page;
        }
        $pager['current_page']=$page;
        $pager['last_page']=$last_page;
        $pager['next_page']=$next_page;
        $pager['page_total']=$page_total;
        $pager['info_total']=$info_total;
        $this->assign("data", $data);
        $this->assign("list", $list);
        $this->assign("pager", $pager);
        $this->display();
    }
    //
    public function exchange(){
        $data['title']='兑换礼品 运营 - 找金银网';
        //获取产品分类列表
        if(I('path.2')>0){
            $page=I('path.2');
        }else{
            $page=1;
        }
        $perpage=10;
        $Model=D("Code");
        $Model->page=$page;
        $Model->perpage=$perpage;
        $list=$Model->get_list();
        //分页相关
        $info_total=$Model->get_info_total();
        $page_total=ceil($info_total/$perpage);
        if($page!=1&&$page_total>1){
            $last_page=$page-1;
        }else{
            $last_page=1;
        }
        if($page_total>$page){
            $next_page=$page+1;
        }else{
            $next_page=$page;
        }
        $pager['current_page']=$page;
        $pager['last_page']=$last_page;
        $pager['next_page']=$next_page;
        $pager['page_total']=$page_total;
        $pager['info_total']=$info_total;
        $this->assign("data", $data);
        $this->assign("list", $list);
        $this->assign("pager", $pager);
        $this->display();
    }
}